﻿using UnityEngine;
using System.Collections;

public class EventDispatchers : IPurge
{
    protected EventDispatchers() { }
    static EventDispatchers s_instance;
    Events.DispatcherT<int> dispatchers = new Events.DispatcherT<int>();

    public void Purge()
    {
        s_instance = null;
    }

    static EventDispatchers Instance
    {
        get
        {
            if (s_instance == null)
                s_instance = new EventDispatchers();
            return s_instance;
        }
    }

    static public void Regist(int eventKey, Events.Listener listener)
    {
        Instance.dispatchers.registEvent(eventKey, listener);
    }

    static public void Remove(int eventKey, Events.Listener listener)
    {
        Instance.dispatchers.removeEvent(eventKey, listener);
    }

    static public void Dispatch(int eventKey, Events.IEvent e = null)
    {
        Instance.dispatchers.dispatchEvent(eventKey, e);
    }

    public void PrePurge()
    {
    }
}
